const htmlTemp = require('./temp.html')
const DI18n = require('di18n-translate')

$().ready(function () {
  let bol = true
  $('.language').on('click', function () {
    bol = !bol
    bol?LOCALE='zh':LOCALE='en'
    translate(LOCALE)
  })

  translate()

  /**
   * 翻译函数
   *
   * @param {*} LOCALE
   */
  function translate(LOCALE) {
    LOCALE = LOCALE ? LOCALE : LOCALE = 'zh'
    const di18n = new DI18n({
      locale: LOCALE, // 语言环境 
      isReplace: false, // 是否开始运行时(适用于没有使用任何构建工具开发流程) 
      messages: { // 语言映射表 
        zh: {
          title: '多一种支付，迎接加密货币的时代 ',
          introTit1: '支持多种主流加密货币。',
          introCon1: '接受BTC、ETH、EOS等多种主流加密货币，让加密货币回归日常生活。',
          introTit2: '商户便捷接入。',
          introCon2: '提供完备的支付接入方案，10分钟，便可使用； 同时也为商户有效的支付安全保障。',
          introTit3: '用户使用无忧',
          introCon3: '支持多端操作，用户只需轻松一扫，便可完成支 付；公链记账，笔笔安全。',

          q1: '闪电支付V1.0上线',
          q2: '优化迭代，增强拓展性',
          q3: '1000+商户，1万+用户',
          q4: '1万+商户，10万+用户',

          apply: '提交申请',
          confirm: '客服确认',
          use: '开始使用',

          join: '立即申请',

          downloadTit: '只需简单操作',
          downloadCon: '您的加密货币就可以用于商店消费，让加密货币回归现实生活',

          come: '敬请期待',
          contact: '联系我们'
        },
        en: {
          title: 'More cryptocurrencies for future',
          introTit1: 'Accept payments via any popular crypto。',
          introCon1: 'Flashpay accepts BTC\ETH\EOS and other сryptos;Cryptos can be used in daily life.',
          introTit2: ' Easy to integrate.',
          introCon2: 'Our product integrates into existing merchant systems easily within 10 minutes; It also provides merchants with effective security.',
          introTit3: 'Easy to pay. ',
          introCon3: 'Flashpay support multi-terminal operation ; Clients can pay by scanning easily.',

          q1: 'Flashpay V1.0',
          q2: 'Update APP& API',
          q3: '1000+ Merchants  &  10,000+ Clients',
          q4: '10,000+ Merchants  &  100,000+ Clients',

          apply: 'Submit an application',
          confirm: 'confirmed',
          use: 'start to use',

          join: 'join now',

          downloadTit: ' Easy to pay.',
          downloadCon: 'Cryptos can be used in daily life.',

          come: 'coming soon',
          contact: 'contact us'
        }
      }
    })
    document.querySelector('#app').innerHTML = di18n.$html(htmlTemp)
  }
})